﻿using System;
using System.Collections.Generic;
using System.Linq;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.GamerServices;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using XAEnima.Core.Stimulation.Internal;

namespace XAEnima.Core.Stimulation.Tipi
{
    public class Square : StimulationBase
    {
        public float ScaleFactorX;
        public float ScaleFactorY;


        public Square(Game game)
            : base(game)
        {
            Stim1 = game.Content.Load<Texture2D>(@"Stimulation/BlackSq");
            Stim2 = game.Content.Load<Texture2D>(@"Stimulation/WhiteSq");
            spriteBatch = (Game.Services.GetService(typeof(SharedContext)) as SharedContext).sprite_batch;
            //ScaleFactorX = (graphics.PreferredBackBufferWidth - 300) / 800.0f;
            // ScaleFactorY = (graphics.PreferredBackBufferHeight - 300) / 600.0f;
            LeftSq = Stim1;
            RightSq = Stim1;
            UpSq = Stim1;
            DownSq = Stim1;
        }

        /// <summary>
        /// Allows the game component to perform any initialization it needs to before starting
        /// to run.  This is where it can query for any required services and load content.
        /// </summary>
        public override void Initialize()
        {
            // TODO: Add your initialization code here

            base.Initialize();
        }

        /// <summary>
        /// Allows the game component to update itself.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        public override void Update(GameTime gameTime)
        {
            // TODO: Add your update code here

            base.Update(gameTime);
        }

        public override void Draw(GameTime gameTime)
        {

            spriteBatch.Begin();
            //Stimolatore Destro
            if (!IsPaused)
            {
                if (left)
                {
                    spriteBatch.Draw(LeftSq, new Rectangle(0, (StateManager.graphic.PreferredBackBufferHeight) / 2 - 75, 150, 150), Color.White);
                }
                //Stimolatore Sinistro
                if (right)
                {
                    spriteBatch.Draw(RightSq, new Rectangle(StateManager.graphic.PreferredBackBufferWidth - 150, ((StateManager.graphic.PreferredBackBufferHeight) / 2) - 75, 150, 150), Color.White);
                }
                //Stimolatore Alto
                if (up)
                {
                    spriteBatch.Draw(UpSq, new Rectangle(StateManager.graphic.PreferredBackBufferWidth / 2 - 75, 0, 150, 150), Color.White);
                }
                //Stimolatore Basso
                if (down)
                {
                    spriteBatch.Draw(DownSq, new Rectangle(StateManager.graphic.PreferredBackBufferWidth / 2 - 75, StateManager.graphic.PreferredBackBufferHeight - 150, 150, 150), Color.White);
                }
            }

            spriteBatch.End();
            base.Draw(gameTime);

        }
    }
}
